value rounded to the NEAREST whole number and handed back as a real - 1.4 becomes 1, 1.5 becomes 2, and -1.5 becomes -2 (an exact tie rounds away from zero).
round(value) -> real| Name | Type |
|---|---|
value | real |
real
value rounded to the NEAREST whole number and handed back as a real. 1.4 becomes 1, 1.5 becomes 2, and -1.5 becomes -2 - an exact tie rounds away from zero.
round and int_round round the same way and differ only in what they hand back. round returns a real, so it goes straight back into more real maths; int_round returns an int. The rule across the language is the one floor and ceil follow: no prefix means a real, and int_ means a whole number.
var snapped_x = round(x / 24) * 24;Snaps x to the NEAREST multiple of 24, so x = 35 gives 24 and x = 37 gives 48. There is no conversion in the middle, because round already returns a real.
Not for "which cell is this position in". round moves to the nearest whole number, which is the wrong cell for half of all positions. That question wants floor (or int_floor when the answer has to be an int).
One call into the Game Boy Advance module's own round-to-nearest call for fixed-point numbers, then back to a real. It costs what int_round costs.
The same rounding as int_round (the GBA module’s own fixed-point nearest-whole-number function), but the answer is a real with nothing after the point, so it can go straight back into real maths - round(x / 24) * 24 snaps x to the nearest multiple of 24 with no conversion in between. Use int_round instead when the result must be an int. Not for "which grid cell is this position in" - that is floor (or int_floor), because round picks the wrong cell half the time.